package factory;

import service.OrderService;
import service.OrderServiceImpl;
import service.UserService;
import service.UserServiceImpl;
import service.RedWineService;
import service.RedWineServiceImpl;

/**
 * Service层工厂类 - 实现工厂设计模式
 * 统一管理Service实例的创建，便于后续扩展和维护
 */
public class ServiceFactory {
    
    // 单例实例（可选优化）
    private static OrderService orderService;
    private static UserService userService;
    private static RedWineService redWineService;
    
    /**
     * 获取OrderService实例
     * @return OrderService实现类实例
     */
    public static OrderService getOrderService() {
        if (orderService == null) {
            orderService = new OrderServiceImpl();
        }
        return orderService;
    }
    
    /**
     * 获取UserService实例
     * @return UserService实现类实例
     */
    public static UserService getUserService() {
        if (userService == null) {
            userService = new UserServiceImpl();
        }
        return userService;
    }
    
    /**
     * 获取RedWineService实例
     * @return RedWineService实现类实例
     */
    public static RedWineService getRedWineService() {
        if (redWineService == null) {
            redWineService = new RedWineServiceImpl();
        }
        return redWineService;
    }
    
    /**
     * 重置所有实例（用于测试或重新初始化）
     */
    public static void reset() {
        orderService = null;
        userService = null;
        redWineService = null;
    }
}
